<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ page import="java.sql.*" %>
<html lang="en" xmlns:th="http://www.thymeleaf.org">

<head>
    <meta charset="UTF-8">
    <title>产品信息列表</title>
    <!-- Bootstrap core CSS -->
    <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
    <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
    <script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="css/user.css">
    <script src="js/user.js"></script>
</head>

<body>

<div class="container-fluid">
    <div class="row">

        <div class="col-sm-12" id="right">
            <ol class="breadcrumb">
                <li class="active">菜单
                </li>
                <li class="active">编辑物料信息
                </li>
            </ol>

            <div class="panel panel-default">
                <div class="panel-heading">
                    填写物料信息
                </div>
                <div class="panel-body">
                    <%
                        //先把获取到所有信息
                        String itemId = "";
                        String itemName = "";
                        String itemClasses = "";
                        String vendorName = "";
                        String site = "";
                        String inboundTime = "";
                        String contact = "";
                        String phoneNumber = "";
                        String itemDescription="";
                        if (request.getParameter("itemId") != null) itemId = request.getParameter("itemId");
                        if (request.getParameter("itemName") != null) itemName = request.getParameter("itemName");
                        if (request.getParameter("itemClasses") != null) itemClasses = request.getParameter("itemClasses");
                        if (request.getParameter("vendorName") != null) vendorName = request.getParameter("vendorName");
                        if (request.getParameter("site") != null) site = request.getParameter("site");
                        if (request.getParameter("inboundTime") != null) inboundTime = request.getParameter("inboundTime");
                        if (request.getParameter("itemDescription") != null) itemDescription = request.getParameter("itemDescription");
                        if (request.getParameter("contact") != null) contact = request.getParameter("contact");
                        if (request.getParameter("phoneNumber") != null) phoneNumber = request.getParameter("phoneNumber");
                    %>
                    <form role="form" class="form-horizontal" action="material_add_do.jsp" method="post">
<%--        <div class="form-group">为一个属性框                --%>
                        <div class="form-group">
                            <label  class="col-sm-2 control-label">物料编号<sup class="text_sup">*</sup></label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" id="itemId" name="itemId"
                                       value="<%=itemId%>"
                                       placeholder="请输入物料编号">
                                <span id="itemIdError" class="errortext">
                                   <%
                                       itemId = request.getParameter("itemId");
                                       if (itemId != null) {
                                           if (itemId == "") {
                                               out.println("物料编号不能为空");
                                           } else if (itemId.length() != 9) {
                                               out.println("格式错误,长度应为9个数字");
                                           }
                                       }
                                   %>
                                </span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">物料名称<sup class="text_sup">*</sup></label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" id="itemName" name="itemName"
                                       value="<%=itemName%>"
                                       placeholder="请输入物料名称">
                                <span id="itemNameError" class="errortext">
                                  <%
                                      itemName = request.getParameter("itemName");
                                      if (itemName != null) {
                                          if (itemName == "") {
                                              out.println("物料名称不能为空");
                                          }
                                      }
                                  %>
                                </span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">材料类型<sup class="text_sup">*</sup></label>
                            <div class="col-sm-8">
                                <select class="form-control" id="itemClasses" name="itemClasses">
                                    <option value="">请选择</option>
                                    <option value="金属" <% if (itemClasses.equals("金属"))
                                        out.print("selected"); %> >金属
                                    </option>
                                    <option value="合金" <% if (itemClasses.equals("合金")) out.print("selected"); %> >
                                        合金
                                    </option>
                                    <option value="复合材料" <% if (itemClasses.equals("复合材料")) out.print("selected"); %> >
                                        复合材料
                                    </option>
                                    <option value="其它" <% if (itemClasses.equals("其它")) out.print("selected"); %> >
                                        其它
                                    </option>
                                </select>
                                <span id="itemClassesError" class="errortext">
                                  <%
                                      itemClasses = request.getParameter("itemClasses");
                                      if (itemClasses != null) {
                                          if (itemClasses == "") {
                                              out.println("请选择材料类型");
                                          }
                                      }
                                  %>
                                </span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">供应商名称<sup
                                    class="text_sup">*</sup></label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" id="vendorName" name="vendorName"
                                       value="<%=vendorName%>"
                                       placeholder="请输入供应商名称">
                                <span id="vendorNameError" class="vendorNametext">
                                  <%
                                      vendorName = request.getParameter("vendorName");
                                      if (vendorName != null) {
                                          if (vendorName == "") {
                                              out.println("供应商名称不能为空");
                                          }
                                      }
                                  %>
                                </span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">厂址<sup
                                    class="text_sup">*</sup></label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" id="site" name="site"
                                       value="<%=site%>"
                                       placeholder="请输入厂址">
                                <span id="siteError" class="errortext">
                                  <%
                                      site = request.getParameter("site");
                                      if (site != null) {
                                          if (site == "") {
                                              out.println("厂址不能为空");
                                          }
                                      }
                                  %>
                                </span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">入库时间<sup class="text_sup">*</sup></label>
                            <div class="col-sm-8">
                                <input type="date" class="form-control" id="inboundTime" name="inboundTime"
                                       value="<%=inboundTime%>"
                                       placeholder="请输入入库时间">
                                <span id="inboundTimeError" class="errortext">
                                  <%
                                      inboundTime = request.getParameter("inboundTime");
                                      if (inboundTime != null) {
                                          if (inboundTime == "") {
                                              out.println("入库时间不能为空");
                                          }
                                      }
                                  %>
                                </span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">物料说明</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" id="itemDescription" name="itemDescription"
                                       value="<%=itemDescription%>"
                                       placeholder="请输入物料说明">

                            </div>
                        </div>
                        <div class="form-group">
                            <label  class="col-sm-2 control-label">联系人<sup class="text_sup">*</sup></label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" id="contact" name="contact"
                                       value="<%=contact%>"
                                       placeholder="请输入联系人姓名">
                                <span id="contactError" class="errortext">
                                  <%
                                      contact = request.getParameter("contact");
                                      if (contact != null) {
                                          if (contact == "") {
                                              out.println("联系人不能为空");
                                          }
                                      }
                                  %>
                                </span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label  class="col-sm-2 control-label">手机号<sup
                                    class="text_sup">*</sup></label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" id="phoneNumber" name="phoneNumber"
                                       value="<%=phoneNumber%>"
                                       placeholder="请输入手机号">
                                <span id="phonenumberError" class="errortext">
                                  <%
                                      phoneNumber = request.getParameter("phoneNumber");
                                      String re = "1\\d{10}"; //1开头且后面要满足有11为手机号
                                      if (phoneNumber != null) {
                                          if (phoneNumber == "") {
                                              out.println("手机号不能为空");
                                          } else if (!phoneNumber.matches(re)) {
                                              out.println("手机号格式输入错误");
                                          }
                                      }
                                  %>
                                </span>
                            </div>
                        </div>

                        <div class="form-group">
                            <div class="col-sm-offset-2 col-sm-10">
                                <button type="submit" class="btn btn-primary">保存</button>
                                <button type="reset" class="btn btn-default">重置</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

</body>

</html>
